/**************************************************************************
 *         Copyright(c) 2007 by Sunplus mMedia  Technology Co., Ltd.       *
 *                                                                         *
 *  This software is copyrighted by and is the property of Sunplus mMedia  *
 *  Technology Co., Ltd. All rights are reserved by Sunplus mMedia Techno- *
 *  logy Co., Ltd. This software may only be used in accordance with the   *
 *  corresponding license agreement. Any unauthorized use, duplication,    *
 *  distribution, or disclosure of this software is expressly forbidden.   *
 *                                                                         *
 *  This Copyright notice "M U S T" not be removed or modified without     *
 *  prior written consent of Sunplus mMedia Technology  Co., Ltd.          *
 *                                                                         *
 *  Sunplus mMedia Technology Co., Ltd. reserves the right to modify this  *
 *  software without notice.                                               *
 *                                                                         *
 *  Sunplus mMedia Technology Co., Ltd.                                    *
 *  19-1, Innovation First Road, Science-Based Industrial Park,            *
 *  Hsin-Chu, Taiwan, R.O.C.                                               *
 *                                                                         *
 **************************************************************************/
#ifndef __SP1K_CALIBRATION_API_H__
#define __SP1K_CALIBRATION_API_H__

/** \file sp1k_calibration_api.h
 * @brief		Spca1528 calibration mode related interface
 */

#include "sp1k_bp_api.h"

/**************************************************************************
 *                           C O N S T A N T S                            *
 **************************************************************************/
#define SP1K_CALIBRATION_CRITERIA_FILE_ID 0x30
#define SP1K_CALIBRATION_OB_FILE_ID 0x31
#define SP1K_CALIBRATION_AWB_FILE_ID 0x32
#define SP1K_CALIBRATION_IQ_FILE_ID 0x33

#if 0
typedef enum {
	SP1K_CALIBRATION_IQ_OB_R = 0,
	SP1K_CALIBRATION_IQ_OB_Gr,
	SP1K_CALIBRATION_IQ_OB_B,
	SP1K_CALIBRATION_IQ_OB_Gb,
	SP1K_CALIBRATION_IQ_AWB_R,
	SP1K_CALIBRATION_IQ_AWB_Gr,
	SP1K_CALIBRATION_IQ_AWB_B,
	SP1K_CALIBRATION_IQ_AWB_Gb,
	SP1K_CALIBRATION_IQ_MAX
} calibrationIq_e;
#endif

typedef enum {
	SP1K_CALIBRATION_OB_R = 0,
	SP1K_CALIBRATION_OB_Gr,
	SP1K_CALIBRATION_OB_B,
	SP1K_CALIBRATION_OB_Gb,
	SP1K_CALIBRATION_OB_MAX
} calibrationOb_e;

typedef enum {
	SP1K_CALIBRATION_AWB_R = 0,
	SP1K_CALIBRATION_AWB_Gr,
	SP1K_CALIBRATION_AWB_B,
	SP1K_CALIBRATION_AWB_Gb,
	SP1K_CALIBRATION_AWB_MAX
} calibrationAwb_e;

typedef enum {
	SP1K_CALIBRATION_PV_OB_R = 0,
	SP1K_CALIBRATION_PV_OB_Gr,
	SP1K_CALIBRATION_PV_OB_B,
	SP1K_CALIBRATION_PV_OB_Gb,
	SP1K_CALIBRATION_PV_OB_MAX
} calibrationPvOb_e;

typedef enum {
	SP1K_CALIBRATION_CRITERIA_OB_LOW_THD = 0,
	SP1K_CALIBRATION_CRITERIA_OB_HIGH_THD,
	SP1K_CALIBRATION_CRITERIA_AE_GID0,
	SP1K_CALIBRATION_CRITERIA_AE_GID1,
	SP1K_CALIBRATION_CRITERIA_AE_GID2,
	SP1K_CALIBRATION_CRITERIA_AE_GID3,
	SP1K_CALIBRATION_CRITERIA_MAX
} calibrationCriteria_e;

typedef enum {
	SP1K_CALIBRATION_MODE_OFF = 0,
	SP1K_CALIBRATION_MODE_STILL_RAW,
	SP1K_CALIBRATION_MODE_AE_TEST,
	SP1K_CALIBRATION_MODE_PV_RAW,
	SP1K_CALIBRATION_MODE_OB,
	SP1K_CALIBRATION_MODE_AWB,
	SP1K_CALIBRATION_MODE_PV_OB,
	SP1K_CALIBRATION_MODE_MAX
} calibrationMode_e;

/**************************************************************************
 *                              M A C R O S                               *
 **************************************************************************/

/**************************************************************************
 *                          D A T A    T Y P E S                          *
 **************************************************************************/

/**************************************************************************
 *                         G L O B A L    D A T A                         *
 **************************************************************************/

/**************************************************************************
 *                 E X T E R N A L    R E F E R E N C E S                 *
 **************************************************************************/

/**************************************************************************
 *               F U N C T I O N    D E C L A R A T I O N S               *
 **************************************************************************/
void sp1kCalibrationModeSet( UINT8 mode );
void sp1kCalibrationObSet( UINT8 enable );
void sp1kCalibrationGammaSet( UINT8 enable );
void sp1kCalibrationLcSet( UINT8 enable );
void sp1kCalibrationAESet( UINT8 enable );
void sp1kCalibrationAWBSet( UINT8 enable );

void sp1kCalibrationAEConfig( UINT16 idx, UINT8 opt );
UINT8 sp1kCalibrationRawCal( UINT32 addr, UINT16 xSize, UINT16 ySize );
UINT8 sp1kCalibrationPvRaw( void );
void sp1kCalibrationAETest( UINT16 fromIdx, UINT16 toIdx, UINT8 opt );
UINT8 sp1kCalibrationLoadCriteria( UINT8 id );
UINT8 sp1kCalibrationAeTestGidStepGet( UINT8 *idx0, UINT8 *idx1, UINT8 *idx2, UINT8 *idx3 );
void sp1kCalibrationAETestSave( UINT16 fromIdx, UINT16 toIdx );
UINT8 sp1kCalibrationLoadIq( UINT8 id );
UINT8 sp1kCalibrationSaveIq( UINT8 id );
void sp1kCalibrationDefaultSizeSet( void );
UINT8 sp1kCalibrationPvYuv( void );

UINT8 sp1kCalBpProc(UINT8 mode);
UINT8 Sp1kAeCalibration(void);
UINT8 Sp1kCalibrationEvParamInit(void);
UINT8 Sp1kCalibrationEvValueGet(void);

/**************************************************************************
 *                   I N T E R N A L   U S E   O N L Y                    *
 **************************************************************************/
UINT8 calibrationRaw( UINT32 addr, UINT16 xSize, UINT16 ySize );
UINT8 calibrationPvRaw( void );
UINT8 calibrationPvYuv( void );
void calibrationObGammeLoad( void );
void sp1kCalibrationPrvRawModeSet(UINT8 mode);
void sp1kCalibrationPrvRawSave(UINT8 mode);

#endif  /* __SP1K_CALIBRATION_API_H__ */

